<?php
	require_once('person.php');
/***********************************************
   Class Guardian
   Keeps record of guardians of students
***********************************************/
	class guardian extends person
	{
		private $guardianid, $studentid, $relid;

// Read record of a guardian by User ID

		public function readByUID($id)
		{
			$this->db->setFetchMode(DB_FETCHMODE_ASSOC);
			$sql='select * from person,guardian where uid=guardianid and uid='.$this->db->quoteSmart($id);
			$result=$this->db->query($sql);
			if (DB::isError($result)) {
				die ($result->getMessage());
			}
			$row=$result->fetchRow();
			if($result->numRows()!=0)
			{
				$this->uid=$row['uid'];
				$this->guardianid=$row['guardianid'];
				$this->name=$row['name'];
				$rel=$row['relid'];
				$this->relid=new relation($rel);
				$this->fname=$row['fnme'];
				$this->mname=$row['mname'];
				$this->dob=$row['dob'];
				$this->studentid=$row['studentid'];
				$this->sex=$row['sex'];
				$this->edu=$row['edu'];
				$this->hno=$row['hno'];
				$this->street=$row['street'];
				$this->city=$row['city'];
				$this->pcode=$row['pcode'];
				$this->email=$row['email'];
				$this->phone=$row['phone'];
				$this->relid=$row['relid'];
				$this->available=1;
			}
			else
				$this->available=0;
			$result->free();
		}

// Constructor


		function __construct($id=0)
		{
			person::__construct();
			$this->readByUID($id);
		}


/*Class guardian ends*/
	}
?>
